package com.bancomer.batch.transferes;

import com.bancomer.batch.pojo.FileHelper;
import com.bancomer.batch.util.LinuxCommand;

public class UploadHdfs {
	public static void uploadFilesHdfs(FileHelper fileHdfs) throws Exception{
		String command = "";
		command = "hadoop fs -put "+fileHdfs.getLocalPath()+fileHdfs.getName()+" "+fileHdfs.getHdfsPath();
		String result = LinuxCommand.execute(command,true);
		if(result.contains("File exists")){
			String deleteCommand = "hadoop fs -rm "+fileHdfs.getHdfsPath()+fileHdfs.getName();
			LinuxCommand.execute(deleteCommand,true);
			LinuxCommand.execute(command,true);
		}
	}
}
